﻿<%@ Page Title="Products" Language="C#" MasterPageFile="~/Users/UserDefault.master" AutoEventWireup="true" CodeFile="Products.aspx.cs" Inherits="Users_Products" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
    <div style="margin-left:0px">
        <div style="float:left"><b>Select a Product Type:</b></div>
        <asp:DropDownList ID="ddlProductTypes" runat="server" 
            DataSourceID="ProductTypesDS" DataTextField="Name" 
            DataValueField="ProductTypeId" AutoPostBack="True">
            </asp:DropDownList>
        <br />
        <br />    
        <asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False" 
            DataSourceID="ProductsDS" DataKeyNames="ProductId" Width="100%" 
            onrowcommand="gvProducts_RowCommand">
            <Columns>
                <asp:BoundField DataField="ProductId" HeaderText="ProductId" 
                    SortExpression="ProductId" Visible="False" />
                <asp:BoundField DataField="ProductTypeId" HeaderText="ProductTypeId" 
                    SortExpression="ProductTypeId" Visible="False" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" >
                <ItemStyle Width="250px" />
                </asp:BoundField>
                <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" 
                    DataFormatString="{0:c}" >
                <ItemStyle HorizontalAlign="Right" Width="150px" />
                </asp:BoundField>
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:CommandField HeaderText="Action" SelectText="Add to Cart" 
                    ShowHeader="True" ShowSelectButton="True">
                <ItemStyle HorizontalAlign="Center" Width="100px" />
                </asp:CommandField>
            </Columns>
        </asp:GridView>    
    </div>
    <asp:ObjectDataSource ID="ProductTypesDS" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductTypes" 
        TypeName="Ample.BLL.ProductTypeBO"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ProductsDS" runat="server" 
            DataObjectTypeName="Ample.Model.Product" InsertMethod="InsertProduct" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductByTypeId" 
            TypeName="Ample.BLL.ProductBO" UpdateMethod="UpdateProduct">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProductTypes" Name="prodTypeId" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
</asp:Content>

